using System;
using System.Collections.Generic;
using System.Text;

namespace Sio.Mdm.Server
{
    /// <summary>
    /// Implementation of base class for all services
    /// </summary>    
    [Service(Name="ServiceStub", DefaultInterface=typeof(IService))]
    public class BaseService : MarshalByRefObject, IService, IRequireServerInstance, IDisposable
    {
        #region Construction
        public BaseService()
        {
        }
        #endregion

        #region Finalizer
        ~BaseService()
        {
            Dispose(false);
        }
        #endregion

        #region Properties

        #region Protected

        #region Server
        private IServer _server;
        /// <summary>
        /// Get instance of server we're running in
        /// </summary>
        public IServer Server
        {
            get
            {
                return _server;
            }
            set
            {
                _server = value;
            }
        }
        #endregion

        #endregion

        #endregion

        #region Methods

        #region Protected
        
        #region Dispose
        protected virtual void Dispose(bool disposing)
        {
            // Just to be sure no pinned instances are left over
            _server = null;
        }
        #endregion

        #endregion

        #endregion

        #region IDisposable Members
        public void Dispose()
        {
            Dispose(true);
        }
        #endregion
    }
}
